package com.busi.framework.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.busi.framework.base.CC;
import com.busi.framework.base.HttpSessionTread;
import com.busi.framework.exception.CheckKeyWordException;

public class DispatchActionTread extends DispatchAction{
	
	public ActionForward execute(ActionMapping mapping, 
			ActionForm form, 
			HttpServletRequest request, 
			HttpServletResponse response){
		ActionForward af = null;
		try{
			String loginName = (String)request.getSession().getAttribute(CC.COMMON_LOGIN_NAME);
			HttpSessionTread.get().setLoginUserName(loginName);
			HttpSessionTread.get().setHttpServletRequest(request);
			af = super.execute(mapping, form, request, response);
		}catch(CheckKeyWordException kwe){
			kwe.printStackTrace();
			String loginUrl = CC.CTX + "/index.do?method=toInputErrorKey";
			af = new ActionForward(loginUrl);
			af.setRedirect(true);
		}catch(Exception ne){
			ne.printStackTrace();
			//String loginUrl = CC.CTX + "/index.do?method=login";
			//af = new ActionForward(loginUrl);
			//af.setRedirect(true);
		}
		
		
		return af;
	}
	
	 
	

}
